﻿using UnityEngine;
using System.Collections;

public class CheckObstacle : MonoBehaviour {

	// Use this for initialization
	
	void Start () {
	
	}
	
	public Vision playerVision;
	// Update is called once per frame
	void Update () 
	{
		if (playerVision.justFlipped)
		{
			rBodiesCount = 0;
		}
		if (rBodiesCount > 0)
		{
			found = true;	
		}
		else
		{
			found = false;
		}
	}
	public bool found;
	private int rBodiesCount;
	void OnTriggerEnter2D(Collider2D other)
	{
		if (other.gameObject.GetComponents<Rigidbody2D>().Length > 0)
		{
			rBodiesCount++;
		}
	}
	void OnTriggerExit2D(Collider2D other)
	{
		if (other.gameObject.GetComponents<Rigidbody2D>().Length > 0)
		{
			rBodiesCount--;
		}
		
	}
}
